package com.zyz.N_反射机制.基本应用.获取运行时类的完整结构;

import java.lang.reflect.Constructor;

/**
 * @author: vick
 * @Date: 2025/4/14
 * @Description:
 * @version: 1.0
 */
public class Test3 {
    public static void main(String[] args) {
        /*
        * 获取当前类中的所有构造器
        * */
        Class<User3> user3Class = User3.class;
        Constructor<?>[] declaredConstructors = user3Class.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }

        /*
        * 获取运行时类的父类
        * */
        Class superclass = user3Class.getSuperclass();
        System.out.println(superclass);

        /*
        * 获取运行时类的所在的包
        * */
        Package aPackage = user3Class.getPackage();
        System.out.println(aPackage);

        /*
         * 获取运行时类的实现接口
         * */
        Class<?>[] interfaces = user3Class.getInterfaces();
        for (Class inter : interfaces) {
            System.out.println(inter);
        }
    }
}
